﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;

namespace Lottery.Client.SL
{
    public class PlayDataInfo
    {
        public int LotteryID;
        public List<PlayData> _mTopPlayData;
        public ObservableCollection<PlayData> LastOpenPlayData;
        public PlayData CurrentPlayData
        {
            get
            {
                if (this._mTopPlayData.Count > 0)
                {
                    return this._mTopPlayData[0];
                }
                return null;
            }
        }

        private PlayData _lastPlayData;
        public PlayData LastPlayData
        {
            get
            {
                bool _isDebug = true;
                if(_isDebug)
                {
                    return _lastPlayData;
                }
                if (this._mTopPlayData.Count > 1)
                {
                    return this._mTopPlayData[1];
                }
                return null;
            }
            set { _lastPlayData = value; }
        }
        public PlayDataInfo(int lotteryid)
		{
			this._mTopPlayData = new List<PlayData>();
			this.LastOpenPlayData = new ObservableCollection<PlayData>();
			this.LotteryID = lotteryid;
		}
        private void d5LXbuuRQV()
        {
            this.LastOpenPlayData.Clear();
            using (List<PlayData>.Enumerator enumerator = this._mTopPlayData.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    PlayData current = enumerator.Current;
                    if (current.BonusNumber != "")
                    {
                        this.LastOpenPlayData.Add(current);
                    }
                    if (this.LastOpenPlayData.Count > 5)
                    {
                        break;
                    }
                }
            }
        }
        public void SetTopPlayData(BinaryReader br)
        {
            lock (this._mTopPlayData)
            {
                this._mTopPlayData.Clear();
                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    this._mTopPlayData.Add(PlayData.GetPlayData(br));
                }
            }
            this.d5LXbuuRQV();
        }
    }
}
